#include "StateManager.h"

StateManager* StateManager::m_pInstance = NULL;

StateManager::StateManager(CGameApp *game)
{
	m_pGame = game;
}

StateManager* StateManager::GetInstance(CGameApp *game)
{
	if (m_pInstance == NULL)
	{
		m_pInstance = new StateManager(game);
	}
	return m_pInstance;
}


void StateManager::Init()
{
	m_pCurrState = new AboutState(this);
	m_pNextState = m_pCurrState;
	m_pCurrState->Init();
}


void StateManager::Update()
{
	if (m_pCurrState != m_pNextState)
	{
		m_pCurrState = m_pNextState;
		m_pCurrState->Init();
	}
	m_pCurrState->Update();
}


void StateManager::Render()
{
	m_pCurrState->Render();
}


void StateManager::Destroy()
{
	m_pCurrState->Destroy();
}


void StateManager::SetNextState(GameState *nextState)
{
	m_pNextState = nextState;
}